﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Vanfa.Entities.User;
using Vanfa.Queries.Sql.DbQueries;
using Vanfa.Queries.Sql.DbModel;
using Vanfa.Common.Crypto;

namespace Vanfa.Biz.User
{
    public class UserProfileMag
    {
        /// <summary>
        /// 填充个人信息
        /// </summary>
        /// <param name="up"></param>
        /// <returns></returns>
        public static bool Fill(vUserPrivInfo up)
        {
            var ret = UserQry.New.Insert(
                        up.UserID,
                        up.ToDbEntity_up(),
                        up.ToDbEntity_uf(),
                        up.ToDbEntity_uc());

            return ret > 0;
        }

        /// <summary>
        /// 填充团队信息
        /// </summary>
        /// <param name="ug"></param>
        /// <returns></returns>
        public static bool Fill(vUserGroupInfo ug)
        {
            var ret = UserQry.New.Insert(
                        ug.UserID,
                        ug.ToDbEntity_up(),
                        ug.ToDbEntity_uc());
            return ret > 0;
        }

        /// <summary>
        /// 读取用户资料信息
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public static vUserPrivInfo LoadPrivInfo(int userID)
        {
            var p = UserQry.New.SelectUserProfile(userID);
            return p.ToBizEntity();
        }

        public static vUserGroupInfo LoadGroupInfo(int userID)
        {
            var p = UserQry.New.SelectGroupProfile(userID);
            return p.ToBizEntity();
        }
    }
}
